<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
class Order extends Controller
{
	public function index(){
                $uid = session('uid');
                $date = date('Y-m-d');
                $time = strtotime($date)+86400;
                $time = date('Y-m-d',$time);
                $start = $date.' 00:00:00';
                $end = $time.' 02:00:00';
		$data = DB::table('ma_order')->alias('a')->join('ma_users b','a.uid = b.uid')->field('b.username,a.*')->where('a.uid',$uid)->where('ordertime', 'between time', [$start,$end])->order('oid desc')->paginate(15);
                $moneys = db('order')->field('SUM(money) as moneys')->where('uid',$uid)->where('ordertime', 'between time', [$start,$end])->select();
                $moneys = round($moneys[0]['moneys'],2);
		$this->assign('data',$data);
                $this->assign('moneys',$moneys);
		return $this->fetch();
	}
}
